package cn.hxy.bladeframework.controller;

import cn.hxy.bladeframework.service.UserService;
import com.blade.ioc.annotation.Inject;
import com.blade.mvc.annotation.*;
import com.blade.mvc.http.Response;

/**
 * @author eric
 * @description:
 * @date 1/4/20 1:51 PM
 */
@Path
public class IndexController {
    @Inject
    private UserService userService;

    @GetRoute("/index")
    public String index() {
        return "index.html";
    }

//    @PostRoute("/save")
    @GetRoute("/save")
    public void saveUser(@Param String username, Response response) {
        System.out.println("username:" + username);
        username= userService.sayHi();
        // 返回json https://lets-blade.com/docs/response.html
        response.json(username);
    }

    @PutRoute("/update")
    public void updateUser(@Param String username) {
        System.out.println("username:" + username);
    }

    @DeleteRoute("/delete/:uid")
    public void updateUser(@PathParam Integer uid) {
        System.out.println("delete user:" + uid);
    }

}

